//
//  MessageCell.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/9/5.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "MessageCell.h"

@interface MessageCell ()

@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *infoLabel;

@end

@implementation MessageCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = ListMaoBackgroundColor;
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.mas_equalTo(self.contentView);
            make.height.mas_equalTo(37);
        }];
        UIView *whiteView = [[UIView alloc] init];
        whiteView.backgroundColor = [UIColor whiteColor];
        whiteView.layer.cornerRadius = 6;
        whiteView.layer.masksToBounds = YES;
        [self.contentView addSubview:whiteView];
        [whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.timeLabel.mas_bottom);
            make.left.mas_equalTo(self.contentView.mas_left).offset(12);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-12);
            make.bottom.mas_equalTo(self.contentView.mas_bottom);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(whiteView.mas_left).offset(12);
            make.right.mas_equalTo(whiteView.mas_right).offset(-12);
            make.top.mas_equalTo(whiteView.mas_top).offset(15);
            make.height.mas_equalTo(21);
        }];
        [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(whiteView.mas_left).offset(12);
            make.right.mas_equalTo(whiteView.mas_right).offset(-12);
            make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(45);
        }];
    }
    return self;
}


- (void)updateInfoCellWithModel {
    
    self.timeLabel.text = @"2018/07/14 10:40";
    self.titleLabel.text = @"您5月的账单已更新";
    self.infoLabel.text = @"明天就是您的账单日, 请及时还款避免逾期. 明天就是您的账单日, 请及";
    [HFQCommonTools changeSpaceForLabel:self.infoLabel withLineSpace:4 WordSpace:0];
}


- (UILabel *)timeLabel {
    
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textColor = HexColor(0x999999);
        _timeLabel.font = [UIFont systemFontOfSize:12];
        [_timeLabel setTextAlignment:NSTextAlignmentCenter];
        
        [self.contentView addSubview:_timeLabel];
    }
    return _timeLabel;
}
- (UILabel *)titleLabel {
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = HexColor(0x454545);
        _titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [_titleLabel setTextAlignment:NSTextAlignmentLeft];
        
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}
- (UILabel *)infoLabel {
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc] init];
        _infoLabel.textColor = HexColor(0x555555);
        _infoLabel.font = [UIFont systemFontOfSize:14];
        [_infoLabel setTextAlignment:NSTextAlignmentLeft];
        _infoLabel.numberOfLines = 2;
        
        [self.contentView addSubview:_infoLabel];
    }
    return _infoLabel;
}





- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
